<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>移动端点击穿透问题</title>
    <style>
        * {
            margin: 0;
            padding: 0
        }

        html,
        body {
            width: 100%;
            height: 100%;
        }

        #wrapper {
            position: relative;
            width: 100%;
            height: 100%;
        }

        #baidu {
            display: block;
            width: 100%;
            height: 200px;
            background-color: orange;
            /* pointer-events: none; */
        }

        #shadow {
            position: absolute;
            text-align: center;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5)
        }

        h1 {
            margin-top: 100px;
            color: white;
        }

        button {
            width: 100px;
            height: 30px;
        }
    </style>
</head>

<body>
    <div id="wrapper">
        <!-- <div id="baidu">点击我去百度</div> -->
        <a href="http://www.baidu.com" id="baidu">点击我去百度</a>
        <div id="shadow">
            <h1>恭喜获奖</h1>
            <button id="btn">确认</button>
        </div>
    </div>

    <script>
        const btn = document.getElementById('btn');
        const shadow = document.getElementById('shadow')
        const baidu = document.getElementById('baidu');

        btn.addEventListener('touchend', (event) => {
            // 阻止默认事件
            // event.preventDefault();
            console.log('touchend事件，将隐藏shadow');
            setTimeout(() => {
                shadow.style.display = "none"
            }, 3000)

            // setTimeout(() => {
            //     baidu.style.pointerEvents = 'auto'
            // }, 300);

        })

        // baidu.addEventListener('touchend', () => {
        //     window.location.href = "http://www.baidu.com"
        // })




    </script>
</body>

</html>